package org.smallframework.springboot;

import org.springframework.boot.context.properties.ConfigurationProperties;
import sf.database.template.TemplateType;
import sf.database.util.OrmValueUtils;


@ConfigurationProperties(prefix = SmallOrmProperties.ORM_PREFIX)
public class SmallOrmProperties {

    public static final String ORM_PREFIX = "smallorm";

    /**
     * 指定扫描若干包,配置示例如下—— <code><pre>
     */
    private String packages;

    /**
     * 对配置了包扫描的路径进行增强检查，方便单元测试
     */
    private boolean enhanceScanPackages = true;


    /**
     * 扫描到实体后，如果数据库中不存在，是否建表 <br>
     * 默认开启
     */
    private boolean createTable = true;

    /**
     * 扫描到实体后，如果数据库中存在对应表，是否修改表 <br>
     * 默认开启
     */
    private boolean alterTable = true;

    /**
     * 扫描到实体后，如果准备修改表，如果数据库中的列更多，是否允许删除列 <br>
     * 默认关闭
     */
    private boolean allowDropColumn;


    //以下为新增.

    /**
     * sql日志开关
     */
    private boolean showSql = true;
    /**
     * 是否打印方法调用,在showSql=true的情况下才有用
     */
    protected boolean showCallChain = false;
    /**
     * 是否使用系统打印日志
     */
    private boolean useSystemPrint = true;
    /**
     * 批处理数量
     */
    private int batchSize = 100;
    /**
     * bean转换方式
     */
    protected OrmValueUtils.BeanValueType beanValueType = OrmValueUtils.BeanValueType.method;

    /**
     * 是否使用tail获取额外属性.
     */
    private boolean useTail = false;

    /**
     * sql模板位置
     */
    private String sqlTemplatePath = "classpath*:sql/**/*.sql";
    /**
     * 是否开启sql模板调试模式
     */
    private boolean sqlTemplateDebug = false;
    /**
     * 是否开启流式迭代
     */
    public boolean openStreamIterator = false;

    /**
     * 使用的sql模板类型
     */
    protected TemplateType sqlTemplateType = TemplateType.enjoy;

    /**
     * 是否需要检查类增强
     */
    protected boolean checkEnhancement = true;

    public String getPackages() {
        return packages;
    }

    public void setPackages(String packages) {
        this.packages = packages;
    }

    public boolean isEnhanceScanPackages() {
        return enhanceScanPackages;
    }

    public void setEnhanceScanPackages(boolean enhanceScanPackages) {
        this.enhanceScanPackages = enhanceScanPackages;
    }

    public boolean isCreateTable() {
        return createTable;
    }

    public void setCreateTable(boolean createTable) {
        this.createTable = createTable;
    }

    public boolean isAlterTable() {
        return alterTable;
    }

    public void setAlterTable(boolean alterTable) {
        this.alterTable = alterTable;
    }

    public boolean isAllowDropColumn() {
        return allowDropColumn;
    }

    public void setAllowDropColumn(boolean allowDropColumn) {
        this.allowDropColumn = allowDropColumn;
    }

    public boolean isShowSql() {
        return showSql;
    }

    public void setShowSql(boolean showSql) {
        this.showSql = showSql;
    }

    public boolean isShowCallChain() {
        return showCallChain;
    }

    public void setShowCallChain(boolean showCallChain) {
        this.showCallChain = showCallChain;
    }

    public OrmValueUtils.BeanValueType getBeanValueType() {
        return beanValueType;
    }

    public void setBeanValueType(OrmValueUtils.BeanValueType beanValueType) {
        this.beanValueType = beanValueType;
    }

    public boolean isUseTail() {
        return useTail;
    }

    public void setUseTail(boolean useTail) {
        this.useTail = useTail;
    }

    public String getSqlTemplatePath() {
        return sqlTemplatePath;
    }

    public void setSqlTemplatePath(String sqlTemplatePath) {
        this.sqlTemplatePath = sqlTemplatePath;
    }

    public boolean isSqlTemplateDebug() {
        return sqlTemplateDebug;
    }

    public void setSqlTemplateDebug(boolean sqlTemplateDebug) {
        this.sqlTemplateDebug = sqlTemplateDebug;
    }

    public int getBatchSize() {
        return batchSize;
    }

    public void setBatchSize(int batchSize) {
        this.batchSize = batchSize;
    }

    public boolean isOpenStreamIterator() {
        return openStreamIterator;
    }

    public void setOpenStreamIterator(boolean openStreamIterator) {
        this.openStreamIterator = openStreamIterator;
    }

    public TemplateType getSqlTemplateType() {
        return sqlTemplateType;
    }

    public void setSqlTemplateType(TemplateType sqlTemplateType) {
        this.sqlTemplateType = sqlTemplateType;
    }

    public boolean isUseSystemPrint() {
        return useSystemPrint;
    }

    public void setUseSystemPrint(boolean useSystemPrint) {
        this.useSystemPrint = useSystemPrint;
    }

    public boolean isCheckEnhancement() {
        return checkEnhancement;
    }

    public void setCheckEnhancement(boolean checkEnhancement) {
        this.checkEnhancement = checkEnhancement;
    }
}
